<?php
session_start();
if (empty($_SESSION['username'])) {
    echo '<script type="text/javascript">window.location.href="../index.php";</script>';
} else {
    $now = time();
    if ($now > $_SESSION['expire']) {
        session_destroy();
        echo '<script type="text/javascript">var r=confirm("Session expire (30 mins)!"); if(r==true){window.location.href="../index.php";}else{window.location.href="index.php";}</script>';
    } else {
        require '../model-db-connection/config.php';
        $config = require '../model-db-connection/qrc_conf.properties.php';
    }
}
?>

<table width="800px">
    <tr>
        <td align="right" style="width:250px">Project Code (หมายเลขโครงการ):</td>
        <td align="left" style="width:250px"><input type="text" class="form-control" id="project_code_search"></td>
        <td align="right" style="width:250px">Project Name (โครงการ):</td>
        <td align="left" style="width:250px"><input type="text" class="form-control" id="project_name_search"></td>
    </tr>
    <tr>
        <td align="right" style="width:250px">Project Type (ประเภทโครงการ):</td>
        <td align="left" style="width:250px">
            <select class="form-control" id="project_type_search" name="project_type_search">
                <option value=""></option>
                <?php
                $sqlSelectProjectType = "SELECT * FROM PROJECT_TYPE;";
                $resultSet = mysql_query($sqlSelectProjectType);
                while ($row = mysql_fetch_array($resultSet)) {
                    echo '<option value="' . $row['project_type_id'] . '">' . $row['project_type_name'] . '</option>';
                }
                ?>                                           
            </select></td>
        <td align="right" style="width:250px">Project Status (สถานะโครงการ):</td>
        <td align="left" style="width:250px">
            <select class="form-control" id="project_status_search" name="project_status_search">
                <option value=""></option>
                <?php
                $sqlSelectProjectType = "SELECT * FROM PROJECT_STATUS;";
                $resultSet = mysql_query($sqlSelectProjectType);
                while ($row = mysql_fetch_array($resultSet)) {
                    echo '<option value="' . $row['project_status_id'] . '">' . $row['project_status_name'] . '</option>';
                }
                ?>                                           
            </select>
        </td>
    </tr>
    <tr>
        <td align="right" style="width:250px">Project Owner (เจ้าของโครงการ):</td>
        <td align="left" style="width:250px">
            <select class="form-control" id="project_owner_search" name="project_owner_search">
                <option value=""></option>
                <?php
                $sqlSelectProjectType = "SELECT * FROM PROJECT_OWNER;";
                $resultSet = mysql_query($sqlSelectProjectType);
                while ($row = mysql_fetch_array($resultSet)) {
                    echo '<option value="' . $row['project_owner_id'] . '">' . $row['project_owner_name'] . '</option>';
                }
                ?>                                           
            </select>
        </td>
        <td align="right" style="width:250px">Customer Name (ชื่อลูกค้า):</td>
        <td align="left" style="width:250px">
            <select class="form-control" id="project_customer_search" name="project_customer_search">
                <option value=""></option>
                <?php
                $sqlSelectProjectType = "SELECT * FROM QRC_CUSTOMER_NAME;";
                $resultSet = mysql_query($sqlSelectProjectType);
                while ($row = mysql_fetch_array($resultSet)) {
                    echo '<option value="' . $row['customer_id'] . '">' . $row['customer_name'] . '</option>';
                }
                ?>                                           
            </select>
        </td>
    </tr>
    <tr>
        <td align="right" style="width:250px">Start Date (วันเริ่มต้น):</td>
        <td align="left" style="width:250px"><input type="text" class="form-control search_date" id="start_search_date" data-date-format="yyyy-mm-dd"></td>
        <td align="right" style="width:250px">End Date (วันสิ้นสุด):</td>
        <td align="left" style="width:250px"><input type="text" class="form-control search_date" id="end_search_date" data-date-format="yyyy-mm-dd"></td>
    </tr>
    <tr>
        <td align="right" style="width:250px">Maximun Search Records:</td>
        <td align="left" style="width:250px">
            <select class="form-control" id="project_limit_search" name="project_limit_search">
                <option value="100">100</option>
                <option value="500">500</option>
                <option value="1000">1000</option>
                <option value="All">--All--</option>                                                       
            </select>
        </td>
    </tr>
</table>
<script type="text/javascript" src="../js/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../css/datepicker.css" media="screen" />
<script type="text/javascript">
    $(document).ready(function() {
        $(".search_date").datepicker();
    });
</script>
